﻿using NightskyMimic.Util;
using System.Collections.Generic;
using System.Linq;

namespace NightskyMimic.Domain
{
    public class Deck
    {
        private List<Card> _cards;

        public int Count
        {
            get { return _cards.Count; }
        }

        public Deck(List<Card> cards) 
        {
            _cards = cards;
        }

        public void Shuffle() 
        {
            List<Card> newList = new List<Card>();

            int count = _cards.Count;
            int cardsNum = _cards.Count;
            for (int i = 0; i < cardsNum; i++) 
            {
                int index = Unicorn.Dash(0, count);
                count--;

                newList.Add(_cards[index]);
                _cards.RemoveAt(index);
            }

            _cards = newList;
        }

        public Card Pick() 
        {
            Card card = _cards[0];
            _cards.RemoveAt(0);
            return card;
        }
    }
}